
****************************************************
****** 			LOCKING DOWN VIOLENCE	      ******
******         Brancati, Birnir, Idlbi 		  ******
******  Statistical Analysis Replication Code ******
****** 					TABLE 1 			  ******
****************************************************

use "LDV_NATLEVEL.dta"

*Time-Set the Data
gen monthnoyear = monthno
replace monthnoyear  = monthno + 12 if year == 2020 
move monthno monthnoyear 
browse if monthnoyear == .
drop if monthnoyear == .

xtset monthnoyear 

*Generate Country Indicators* 
gen syria  = 0 
replace syria = 1 if iso == 760 
gen iraq = 0 
replace iraq = 1 if iso  == 368
gen egypt = 0 
replace egypt = 1 if iso  == 818

*generate lags*
sort iso week 
foreach  variable of varlist  ramadan covid19eracase covid19eradeath oilprice uscovid19eradeath uscovidcumdeathcdc uscovidcumdeathdatecdc uscovidcumdeathswho internalbanstri curfewsdi curfewstri neighbanstri covidcumdeathswho covidcumdeathsdatewho usforces iranforces sdfforces gosforces goiforces pmfforces goeforces securityaidtotal economicaidusaid humanitarianaidunfts covidaidunfts covidaidstate internalbansdi neighbansdi neighbansdi2 ISIScurfewsdi nonISIScurfewsdi nonISISnternalbansdi nonISISneighbansdi {
bysort iso: gen `variable'_lag = `variable'[_n-1]
}
destring, replace
***** *** *** *** *** *** *** *** *** *** *** ** * ANALYSIS ***** *** *** *** *** *** *** *** *** *** *** ***** *** *** *** 


**Table 1**
*Model 1, DV: ISIS-initiated Violent Events (includes likely). IV: First Reported COVID-19 Death 

gen oilpricelag_iraq = oilprice_lag*iraq
xtnbreg isisandlikely_wk covid19eradeath_lag vsisis_wklag oilprice_lag oilpricelag_iraq ramadan iraq egypt, re
outreg2 using Table1b, replace 
test oilprice_lag iraq oilpricelag_iraq
margins, at(ramadan=0)
margins, at(ramadan=1)
margins, at(oilpricelag_iraq=25 oilprice_lag=25 iraq=1 egypt=0)
margins, at(oilpricelag_iraq=50 oilprice_lag=50 iraq=1 egypt=0)

predict zhat1, nu0
margins, at(ramadan=(0(1)1)) predict(nu0) 
tabstat zhat1 if ramadan == 0 
tabstat zhat1 if ramadan == 1 
 
*Model 2, DV: ISIS-initiated Violent Events (includes likely). IV: Cummulative Number of COVID-19 Deaths

xtnbreg isisandlikely_wk covidcumdeathswho_lag vsisis_wklag oilprice_lag oilpricelag_iraq ramadan iraq egypt, re
outreg2 using Table1b, append
test oilprice_lag iraq oilpricelag_iraq

*Model 3, DV: ISIS-initiated Violent Events (includes likely). IV: First Reported COVID-19 Death [interaction Iraq] 
 
gen covid19eradeathlag_iraq = covid19eradeath_lag*iraq
xtnbreg isisandlikely_wk covid19eradeath_lag covid19eradeathlag_iraq vsisis_wklag oilprice_lag ramadan iraq egypt, re
outreg2 using Table1b, append
test covid19eradeathlag_iraq iraq covid19eradeath_lag
margins, at(covid19eradeathlag_iraq=0 covid19eradeath_lag=0 iraq=1 egypt=0)
margins, at(covid19eradeathlag_iraq=1 covid19eradeath_lag=1 iraq=1 egypt=0)
margins, at(covid19eradeathlag_iraq=0 covid19eradeath_lag=0 iraq=0 egypt=1)
margins, at(covid19eradeathlag_iraq=0 covid19eradeath_lag=1 iraq=0 egypt=1)
margins, at(covid19eradeathlag_iraq=0 covid19eradeath_lag=0 iraq=0 egypt=0)
margins, at(covid19eradeathlag_iraq=0 covid19eradeath_lag=1 iraq=0 egypt=0)

predict zhat3, nu0
*graph*
margins, at(covid19eradeathlag_iraq=0 covid19eradeath_lag=0 iraq=1 egypt=0) predict(nu0) 
margins, at(covid19eradeathlag_iraq=1 covid19eradeath_lag=1 iraq=1 egypt=0) predict(nu0) 
browse zhat3 if iraq == 1 & covid19eradeath_lag == 0
browse zhat3 if iraq == 1 & covid19eradeath_lag == 1
tabstat zhat3 if iraq == 1 & covid19eradeath_lag == 0
tabstat zhat3 if iraq == 1 & covid19eradeath_lag == 1

*Model 4, DV: ISIS-initiated Violent Events (includes likely). IV: Cummulative Number of COVID-19 Deaths [interaction Iraq] 

gen covidcumdeathswholag_iraq = covidcumdeathswho_lag*iraq 
xtnbreg isisandlikely_wk covidcumdeathswho_lag covidcumdeathswholag_iraq vsisis_wklag oilprice_lag ramadan iraq egypt, re
outreg2 using Table1b, append
test covidcumdeathswholag_iraq iraq covidcumdeathswho_lag 
margins, at(covidcumdeathswholag_iraq=0 covidcumdeathswho_lag=0 iraq=1 egypt=0)
margins, at(covidcumdeathswholag_iraq=500 covidcumdeathswho_lag=500 iraq=1 egypt=0)
margins, at(covidcumdeathswholag_iraq=0 covidcumdeathswho_lag=0 iraq=0 egypt=1)
margins, at(covidcumdeathswholag_iraq=0 covidcumdeathswho_lag=500 iraq=0 egypt=1)
margins, at(covidcumdeathswholag_iraq=0 covidcumdeathswho_lag=0 iraq=0 egypt=0)
margins, at(covidcumdeathswholag_iraq=0 covidcumdeathswho_lag=500 iraq=0 egypt=0)

predict zhat4, nu0
*graph
browse zhat4 if iraq == 1 
browse zhat4 if iraq == 1
margins, at(covidcumdeathswholag_iraq=0 covidcumdeathswho_lag=0 iraq=1 egypt=0) predict(nu0)
margins, at(covidcumdeathswholag_iraq=1103 covidcumdeathswho_lag=1103  iraq=1 egypt=0) predict(nu0)  
tabstat zhat4 if covidcumdeathswholag == 0 &  iraq == 1
tabstat zhat4 if covidcumdeathswholag == 1103 &  iraq == 1
 
*Model 5, DV: DEADLY ISIS-initiated Violent Events (includes likely). IV: First Reported COVID-19 Death [interaction Iraq] 

xtnbreg isisandlikelyfatal_wk covid19eradeath_lag covid19eradeathlag_iraq vsisis_wklag oilprice_lag ramadan iraq egypt, re
outreg2 using Table1b, append
test covid19eradeathlag_iraq iraq covid19eradeath_lag
margins, at(covid19eradeathlag_iraq=0 covid19eradeath_lag=0 iraq=1 egypt=0)
margins, at(covid19eradeathlag_iraq=1 covid19eradeath_lag=1 iraq=1 egypt=0)
margins, at(covid19eradeathlag_iraq=0 covid19eradeath_lag=0 iraq=0 egypt=1)
margins, at(covid19eradeathlag_iraq=0 covid19eradeath_lag=1 iraq=0 egypt=1)
margins, at(covid19eradeathlag_iraq=0 covid19eradeath_lag=0 iraq=0 egypt=0)
margins, at(covid19eradeathlag_iraq=0 covid19eradeath_lag=1 iraq=0 egypt=0)

predict zhat5, nu0
*graph*
margins, at(covid19eradeathlag_iraq=0 covid19eradeath_lag=0 iraq=1 egypt=0) predict(nu0)
margins, at(covid19eradeathlag_iraq=1 covid19eradeath_lag=1 iraq=1 egypt=0) predict(nu0)  
browse zhat5 if iraq == 1 
browse zhat5 if iraq == 1
tabstat zhat5 if covid19eradeathlag == 0 &  iraq == 1
tabstat zhat5 if covid19eradeathlag == 1 &  iraq == 1


